package part_2;

import javax.swing.JOptionPane;

public class Mopeds {

	public static void main(String[] args) {
		//INPUT:    inp = JOptionPane.showConfirmDialog(null, "text");
		//MESSAGE:  JOptionPane.showMessageDialog(null, "text");
			
		int mopedType;
		int rentedTime;
		boolean weekday;
		double cost;
		
		do {
			mopedType = Integer.parseInt(JOptionPane.showInputDialog(null, "Moped type [Solex=0/Mohawk=1/BMW=2]"));
		} while (!((mopedType == 0) || (mopedType == 1) || (mopedType == 2)));
			
		do {
		rentedTime = Integer.parseInt(JOptionPane.showInputDialog(null, "Rented time [hours]"));
		} while (rentedTime < 0);
		
		weekday = Boolean.parseBoolean(JOptionPane.showInputDialog(null, "Is it a weekday [true/false]?"));
		
		switch (mopedType) {
			case 0: 		//Solex
				if (weekday){
					if(rentedTime <= 3)
						cost = 12.0;
					else
						cost = (12.0 + (2.2 * (rentedTime -3)));
				} else {
					if(rentedTime <= 3)
						cost = 20.0;
					else
						cost = (20.0 + (7.0 * (rentedTime -3)));
				}
				JOptionPane.showMessageDialog(null, "The cost of the rent is: " + cost);
				break;
			case 1:
				if (weekday){
					if(rentedTime <= 4)
						cost = 22.0;
					else
						cost = (22.0 + (3.2 * (rentedTime -4)));
				} else {
					if(rentedTime <= 4)
						cost = 35.0;
					else
						cost = (35.0 + (8.5 * (rentedTime -4)));
				}
				JOptionPane.showMessageDialog(null, "The cost of the rent is: " + cost);
				break;
			case 2:
				if (weekday){
					if(rentedTime <= 3)
						cost = 35.0;
					else
						cost = (35.0 + (3.5 * (rentedTime -5)));
				} else {
					if(rentedTime <= 3)
						cost = 45.0;
					else
						cost = (45.0 + (9.8 * (rentedTime -5)));
				}
				JOptionPane.showMessageDialog(null, "The cost of the rent is: " + cost);
				break;
			default:
				JOptionPane.showMessageDialog(null, "An unexpected error has occurd");
				break;
		}
		
	}

}
